# coding:utf-8
"""
Created by shenyufeng at 2018/7/31
"""
import json
import dredd_hooks as hooks

from jsmin import jsmin

stash = {}
api_username = "XXX"
api_password = "XXX"
api_uri = "XXX"


@hooks.before_each
def add_token(transaction):
    transaction['request']['headers'][
        'Token'] = "2|1:0|10:1533017229|3:sid|32:NWI1ZmZjOGQyODJlZTJhNDhhMzdmOTZj|811b4c19bd03754ad86c828ca3442e56a120c6cddf50578a9439560d054b4a65"

    transaction['request']['body'] = jsmin(transaction['request']['body'])
    transaction['expected']['body'] = jsmin(transaction['expected']['body'])


@hooks.after('客户管理 > 客户资产值信息 > 客户资产值信息')
def check(transaction):
    res = json.loads(transaction['real']['body'])
    # print(res['response_time'])
    try:
        pass
        # assert 100 > res['response_time'], "响应时间太长"
    except AssertionError as ae:
        transaction['fail'] = str(ae)
